package com.sphd.beautysalon.presenter;


import com.android.volley.VolleyError;
import com.sphd.beautysalon.info.InvestRuleInfo;
import com.sphd.beautysalon.info.InvestorInfo;
import com.sphd.beautysalon.model.FundingModelImpl;
import com.sphd.beautysalon.view.FundingView;

import java.util.List;

/**
 * Created by Hu on 2016/11/03
 */

public class FundingPresenterImpl implements FundingPresenter {
    private FundingView fundingView;
    private FundingModelImpl fundingModel;

    public FundingPresenterImpl(FundingView fundingView) {
        this.fundingView = fundingView;
        fundingModel = new FundingModelImpl();
    }

    @Override
    public void addData(String url) {
        fundingView.showLoading();
        fundingModel.sendUrl(url, this);
    }

    @Override
    public void sendError(VolleyError error) {
        fundingView.dissLoading();
    }

    @Override
    public void sendRes(List<InvestorInfo> investorInfos,
                        List<InvestRuleInfo> investRuleInfos,
                        int status, int repeal_apply, int import_apply, double sum) {
        if (status == 0) {
            fundingView.startSetFunding();
        } else {
            fundingView.setSumText(sum);
            fundingView.setrepealNo(repeal_apply);
            fundingView.setimportNo(import_apply);
            fundingView.setResRule(investRuleInfos);
            fundingView.setRfAdapter(investorInfos);
        }
        fundingView.dissLoading();

    }
}